Fix NavigationServer3D.get_closest_point_to_segment()
with use_collision
#92850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When calling
NavigationServer3D.get_closest_point_to_segment()
with the parameteruse_collision
set to true, it always returns (0, 0, 0).The bug can be seen here, where
closest_point_d
is incorrectly set to the same value asd
on the first line, which hinders theelse if
below it from ever being true.godot/modules/navigation/nav_map.cpp
Lines 620 to 628 in e96ad5a
It's obvious that
closest_point_d
andclosest_point
should always be set together, so I can't imagine what the intention behind that first line could have been.(I find the way these lines are written to be confusing with unnecessary duplication, but I resisted the urge to refactor them.)